﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EventManager.Model.Factory
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly IDbFactory _dbFactory;

        private EMDbContext _context;
        public EMDbContext Context
        {
            get { return _context ?? (_context = _dbFactory.Get()); }
        }


        public UnitOfWork(IDbFactory dbFactory)
        {
            _dbFactory = dbFactory;
        }


        public void Commit()
        {
            Context.SaveChanges();
        }
    }
}
